<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/base.css" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/style.css" />
    <title>半岛云</title>
<style>
	
</style>    
</head>
<body>
	<div class="wrap">
		<!--标题栏-->
		<div class="fixed_top">
			<div class="top-l"><a href="javascript:window.history.back()"><i class="icons">&#xe626;</i></a></div>
			<h1>登录</h1>
			<div class="top-r hide"><a href="javascript:;"><i class="icons">&#xe601;</i></a></div>
		</div>
		

		
		<div class="container">
		<form class="login-form" id="userForm">
			<ul>
				<li>
					<label></label>
					<div class="username"><i class="icons">&#xe614;</i><input type="text" value="" name="username" id="username"  placeholder="请输入您的邮箱"/></div>
				</li>
				<li>
					<label></label>
					<div class="password"><i class="icons">&#xe787;</i><input type="password" value=""  name="password" id="password" placeholder="请输入您的登录密码"/></div>
				</li>
				<li>
					<label></label>
					<div class="password"><i class="icons">&#xe60e;</i><input type="text" value=""  name="code" id="code" placeholder="请证明你不是机器人" class="login-code-input"/>							
						<a href="javascript:void(0);" onclick="changeImg()" class="aui-child aui-child-img"><img  class="login-code" src="/${BasePath}/user/validateCode" alt="" id="imgObj" /></a>
					</div>
				</li>
			</ul>
			<div class="log">
				<a  href="javascript:;" class="btn-login" id="nextBtn">登录</a>
			</div>
			<div class="log-more">
				<a href="register.html" class="btn-reg">立即注册</a>
				<a href="password.html" class="btn-psw">忘记密码？</a>
			</div>
		</form>
		</div>
	</div>
</body>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/jquery-1.7.js" ></script>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/public.js" ></script>
<script type="text/javascript">
    $(function(){
		//AJAX提交以及验证表单
		$('#nextBtn').click(function(){
			var username = $('#username').val();
			var passwd = $('#password').val();
			var usernameReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; //邮件正则
			if(username == ''){
				zz1('请填写您的邮箱~');
			}else if(!usernameReg.test(username)){
				zz1('您的邮箱格式错咯~');
			}else if(passwd == ''){
				zz1('请填写您的密码~');
			}else{
				$("#nextBtn").attr('disabled',true);
				$("#nextBtn").html("登录中...");
		        $.ajax({
		            type: 'post',
		            url: "/${BasePath}/user/doLogin",
		            data: $('#userForm').serialize(),
		            dataType: 'json',
		            success: function(data){
		                if (data.code == "1"){
		                	zz1(data.msg,"/${BasePath}/main/index",2500);
		                }else{
		    				$("#nextBtn").attr('disabled',false);
		    				$("#nextBtn").html("登录");
		                	changeImg();
		                	zz1(data.msg);
		                }
		            }
		        });
			}
		});       	
    })
       // 刷新图片
    function changeImg() {
        var imgSrc = $("#imgObj");
        var src = imgSrc.attr("src");
        imgSrc.attr("src", changeUrl(src));
    }
    //为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳
    function changeUrl(url) {
        var timestamp = (new Date()).valueOf();
        var index = url.indexOf("?",url);
        if (index > 0) { 
			 url = url.substring(0, index);
			}
        if ((url.indexOf("&") >= 0)) {
            url = url + "×tamp=" + timestamp;
        } else {
            url = url + "?timestamp=" + timestamp;
        }
        return url;
    }
</script>
</html>